package com.asset.dispoal.business.casedispose.service.command;

import com.asset.dispoal.business.casedispose.domain.db.mapper.CasedisposeMapper;
import com.asset.dispoal.business.casedispose.dto.CaseDisposeResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import tech.mhuang.pacebox.core.ddd.BaseCommand;
import tech.mhuang.pacebox.springboot.protocol.Result;

@Component
public class CaseDisposeDetailGetCommand implements BaseCommand<String, Result<CaseDisposeResponse>> {

    @Autowired
    CasedisposeMapper casedisposeMapper;

    @Override
    public Result<CaseDisposeResponse> execute(String caseId) {
        CaseDisposeResponse caseDisposeResponse = casedisposeMapper.getResponseById(caseId);
        if (caseDisposeResponse.getPrepaymentPeriod() != null) {
            caseDisposeResponse.setMediationList(casedisposeMapper.queryMediationByCaseId(caseId));
        }
        return Result.ok(caseDisposeResponse);
    }
}
